/*
 * @(#)PartOfSpeech.java	1.0 08/01/07
 *
 * Copyright 2007 Fabio Gasparetti. All rights reserved.
 */

package org.tabularium.text.nlp.wordnet;

import java.util.HashMap;
import java.util.Map;

/**
 * Just a helper for identifying/comparing part of speeches internally
 * represented by interegers.
 * <p>
 * WordNet defines "part of speech" as either noun, verb, adjective, or adverb.
 * Same as syntactic categories.
 * 
 * @author Fabio Gasparetti
 * @version 1.0, 08/01/07
 */
public final class PartOfSpeech {
	/** String representations of POS tags */
	public static final String[] POS_STRING = { "NOUN", "VERB", "ADJECTIVE",
			"ADVERB", "ARTICLE", "PRONOUN", "INTERJECTION", "CONJUCTION",
			"STOP", "PREPOSITION" };

	protected Map posConversionMap = null;

	/** UNKNOWN */
	public static final int UNKNOWN = -1;

	/** NOUN */
	public static final int NOUN = 0;

	/** VERB */
	public static final int VERB = 1;

	/** ADJECTIVE */
	public static final int ADJECTIVE = 2;

	/** ADVERB */
	public static final int ADVERB = 3;

	/** ARTICLE */
	public static final int ARTICLE = 4;

	/** PRONOUN */
	public static final int PRONOUN = 5;

	/** ADVERB */
	public static final int INTERJECTION = 6;

	/** conjunction */
	public static final int CONJUCTION = 7;

	/** punctuation */
	public static final int STOP = 8;

	/** PREPOSITION */
	public static final int PREPOSITION = 9;

	/** Min value used to represent POS. Useful for interations */
	public static final int MIN_POS = 0;

	/** Max value used to represent POS. Useful for interations */
	public static final int MAX_POS = 9;

	private PartOfSpeech() {
	}

	/**
	 * The POS string must be one of the constant defined in the class.
	 */
	public static int toInteger(String pos) {
		for (int i = 0; i < POS_STRING.length; i++) {
			if (POS_STRING[i].compareToIgnoreCase(pos) == 0)
				return i;
		}
		return -1;
	}

	public static String toString(int pos) {
		if (pos >= MIN_POS && pos <= MAX_POS)
			return POS_STRING[pos];
		return "UNKNOWN";
	}

}
